﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
using System.Data;
using Comm;
using BusinessFacade;
using Entities;

namespace MedicareNoteManagerWeb.Web
{
    public partial class PersongroupmanageSelect : BasePage
    {
        med_persongroupmanage_Model model1 = new med_persongroupmanage_Model();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                model1 = (med_persongroupmanage_Model)Session["PersonGroupManageModel"];
                BindDrop();
                PageGrid1_Invalidate(sender, e);
                PageGrid1_SelectedValueChanged(sender, e);
                lbl_Message.Text = "";
            }
        }
        public void BindDrop()
        {
            FillDropDownList("GetDrop", "AreaID", "AreaName", "请选择区域", this.DropArea);
        }

        public static int a = 1;
        /// <summary>
        /// 选择行获取行的信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void PageGrid1_SelectedValueChanged(object sender, EventArgs e)
        {
            Busi_med_persongroupmanage u = new Busi_med_persongroupmanage();
            med_persongroupmanage_Model model = u.GetListModel(int.Parse(PageGrid1.SelectedValue));

            if (a % 2 == 0)
            {
                a++;
                string s_url;

                s_url = "Noteplan.aspx?name=" + model.Area;

                Response.Redirect(s_url);

            }
            else
            {
                a++;
            }
        }

        protected void PageGrid1_Invalidate(object sender, EventArgs e)
        {
            Busi_med_persongroupmanage users = new Busi_med_persongroupmanage();
            DataTable dt = users.GetList(txt_PersonState.Text.Trim(), int.Parse(DropArea.SelectedValue));
            PageGrid1.BindFullDataTable(dt, true);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                PageGrid1_Invalidate(sender, e);
                PageGrid1_SelectedValueChanged(sender, e);
                // lbl_Message.Text = "";
            }
            catch (Exception ex)
            {
                // lbl_Message.Text = ex.Message.ToString();
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            //PageGrid1.ResetState();
            //txt_Content.Value = "";
            //txt_Explain.Value = "";
            //txt_Name.Text = "";
            //DropArea.SelectedValue = "0";
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button3_Click(object sender, EventArgs e)
        {
            try
            {
                //int id = int.Parse(PageGrid1.SelectedValue);
                //Busi_nm_notemessage.Delete(id);
                PageGrid1_Invalidate(sender, e);
                PageGrid1_SelectedValueChanged(sender, e);
                MessageBox.Show(this.Page, "删除成功！");
            }
            catch (Exception ex)
            {
                // lbl_Message0.Text = ex.Message;
            }
        }
    }
}